﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Harmonogramowanie
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonHarm_Click(object sender, EventArgs e)
        {
            CGraph G = new CGraph();
            SetPer pi = new SetPer();

            //obciążenie wezłów (czasy wykonywania zadania)
            int[] tm = { 0, 2, 1, 2, 2, 6, 2, 1, 3, 1, 3, 5, 2, 3, 4, 1, 1, 2, 3, 3 };
            //przydział zasobów
            int[] rs = { 0, 1, 1, 2, 3, 3, 4, 3, 5, 3, 6, 3, 6, 6, 3, 5, 2, 2, 2, 3 };


            //inicjalizacja grafu
            G.Init(19);

            //dodawanie następników
            G.addarc(1, 2); G.addarc(1, 3); G.addarc(1, 4);
            G.addarc(2, 5);
            G.addarc(3, 5);
            G.addarc(4, 5);
            G.addarc(5, 6);
            G.addarc(6, 7); G.addarc(6, 10);
            G.addarc(7, 8); G.addarc(7, 9);
            G.addarc(8, 9);
            G.addarc(9, 14);
            G.addarc(10, 11); G.addarc(10, 12);
            G.addarc(12, 13); G.addarc(12, 15); G.addarc(12, 17);
            G.addarc(13, 14);
            G.addarc(15, 16);
            G.addarc(16, 19);
            G.addarc(17, 16); G.addarc(17, 18);
            G.addarc(18, 19);

            for (int i = 1; i <= G.n; i++) G.Weights[i] = tm[i];
            for (int i = 1; i <= G.n; i++) G.Res[i] = rs[i];

            //Tworzenie permutacji
            int[] pis ={ 0, 1, 2, 0, 3,17, 16, 18,0, 4, 5, 7, 9, 11, 14, 19, 0, 6, 12, 13, 0, 8, 15, 0, 10, 0 };

            
         int op = 19, m=6;
         pi.init(op, m);
            for (int i = 1; i <= op+m; i++) pi.pi[i]=pis[i];
            pi.CreatePS();


            int [] lista = ScheduleCore.TopOrder(G, pi);

            int a = 4;


        }
    }
}
